
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    var status=$('#status').val();
    var Controller = {

        index: function () {


            if(status==1 || status==''){
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'user/expenditure/index',
                        table: 'users',
                    }
                });

                var table = $("#table");
                // 初始化表格
                table.bootstrapTable({

                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    pk: 'user_id',
                    sortName: 'user_id',
                    columns: [
                        [
                            {field: 'user_id', title: __('User_id'),},
                            {field: 'user_name', title: __('User_name')},
                            {field: 'full_name', title: __('Full_name')},
                            {field: 'count', title: "悬赏支出次数",operate:false},
                            {field: 'sum', title:"悬赏支出总额",operate:false},
                            {field: 'service_sum', title:"平台费总额",operate:false},
                            {field: 'click_price', title:"退还总额",operate:false},

                        ]
                    ],
                    showToggle: false,
                    showColumns: false,
                    search:false,
                });
            }
            if(status==2){
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'user/expenditure/index2',
                        table: 'users',
                    }
                });

                var table = $("#table");
                // 初始化表格
                table.bootstrapTable({

                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    pk: 'id',
                    sortName: 'id',
                    columns: [
                        [
                            {field: 'user_id', title: __('User_id'),},
                            {field: 'user_name', title: __('User_name')},
                            {field: 'full_name', title: __('Full_name')},
                            {field: 'count', title: "付费次数",operate:false},
                            {field: 'click_amount', title:"封顶总额",operate:false},
                            {field: 'service_price', title:"平台费总额",operate:false},
                            {field: 'sum', title:"支付总额",operate:false},
                            {field: 'click_price', title:"退还总额",operate:false},
                        ]
                    ],
                    showToggle: false,
                    showColumns: false,
                    search:false,
                });
            };
            if(status==3){
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'user/expenditure/index3',
                        table: 'users',
                    }
                });

                var table = $("#table");
                // 初始化表格
                table.bootstrapTable({

                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    pk: 'id',
                    sortName: 'id',
                    columns: [
                        [
                            {field: 'user_id', title: __('User_id'),},
                            {field: 'user_name', title: __('User_name')},
                            {field: 'full_name', title: __('Full_name')},
                            {field: 'count', title: "付费次数",operate:false},
                            {field: 'amount', title:"付费总额",operate:false},
                        ]
                    ],
                    showToggle: false,
                    showColumns: false,
                    search:false,
                });
            };
            if(status==4){
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'user/expenditure/index4',
                        table: 'users',
                    }
                });

                var table = $("#table");
                // 初始化表格
                table.bootstrapTable({

                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    pk: 'id',
                    sortName: 'id',
                    columns: [
                        [
                            {field: 'user_id', title: __('User_id'),},
                            {field: 'user_name', title: __('User_name')},
                            {field: 'full_name', title: __('Full_name')},
                            {field: 'count', title: "付费次数",operate:false},
                            {field: 'amount', title:"付费总额",operate:false},
                        ]
                    ],
                    showToggle: false,
                    showColumns: false,
                    search:false,
                });
            };
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});